﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Business {
    public static class TimeSpanExtensions {
        public static string Friendly(this TimeSpan ts) {
            var days = Math.Abs(ts.TotalDays);
            var years = (int)(days / 365);
            var months = (int)(days % 365 / 30);

            var msg = new StringBuilder();
            if (years > 0)
                msg.AppendFormat("{0}年", years);
            if (months > 0)
                msg.AppendFormat("{0}个月", months);
            return msg.ToString();
        }
    }
}
